package cate.game.role.res.rune;

import cate.game.role.Role;
import cate.game.role.RoleDependent;
import cate.game.train.rune.msg.RuneResResp;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.HashMap;
import java.util.Map;

@NoteClass(value = "徽章")
public class RoleRune extends RoleDependent {
    @NoteField(value = "徽章各种类型的重铸次数")
    public Map<Integer, Integer> map;

    @NoteField(value = "熔炼值")
    public int meltingNum;

    @NoteField(value = "合成次数")
    public int times;

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if (map == null) {
            map = new HashMap<>();
        }
    }

    public void add(int type) {
        int num = get(type);
        map.put(type, ++num);
    }

    public int get(int type) {
        map.putIfAbsent(type, 0);
        return map.get(type);
    }

    public void addTimes(){
        times++;
    }

    public int getTimes(){
        return times;
    }

    public void noticeUpdate() {
        role.sendNow(new RuneResResp(this));
    }
}
